﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data ;

namespace ntc_permit_dept_hr
{
   public class dbAccess
    {

       private string connS = "";
       public dbAccess() {
          // connS = a;
           connS = @"Data Source=ANUSHKA-PC;Initial Catalog=NTC;Integrated Security=True;Pooling=False";
       }

       //FOR UPDATE QUARIES

       public bool UPDATE(string sql) {

           SqlConnection conn = new SqlConnection(connS);
           SqlCommand cmd = new SqlCommand(sql, conn);

           try
           {
               conn.Open();
               cmd.ExecuteNonQuery();
               return true;
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message );
               return false;
           }
           finally {

               conn.Close();
               conn.Dispose();
               cmd.Dispose();

           }
       }

       //FOR SELECT QUARIES
       public DataTable SELECT(string sql) {

           DataTable dt = new DataTable("info");
           SqlDataAdapter da = new SqlDataAdapter(sql, connS);

           try
           {
               da.Fill(dt);
               return dt;
           }
           catch (Exception ex)
           {
               MessageBox.Show(ex.Message);
               return null;
           }
           finally {

               da.Dispose();
               dt.Dispose();
           }
       }


       internal bool UPDATE()
       {
           throw new NotImplementedException();
       }
    }
}